/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.mes.base.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.tool.api.R;
import org.springblade.modules.mes.base.entity.PrdInfo;
import org.springblade.modules.mes.base.vo.PrdInfoVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 产品信息 服务类
 *
 * @author BladeX
 * @since 2020-09-08
 */
public interface IPrdInfoService extends BaseService<PrdInfo> {

	/**
	 * 不分页
	 * @param prdInfoVO
	 * @return
	 */
	List<PrdInfoVO> getPrdInfoVOList(PrdInfoVO prdInfoVO);
	/**
	 * 不分页
	 * 根据名称模糊搜索，如果没传返回空
	 * @param prdName
	 * @return
	 */
	List<PrdInfoVO> listByName(String prdName, String productType);

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param prdInfo
	 * @return
	 */
	IPage<PrdInfoVO> selectPrdInfoPage(IPage<PrdInfoVO> page, PrdInfoVO prdInfo);

	/**
	 * 顶层产品列表 分页
	 *
	 * @param page
	 * @param prdInfo
	 * @return
	 */
	IPage<PrdInfoVO> selectTopPrdInfoPage(IPage<PrdInfoVO> page, PrdInfoVO prdInfo);

//	/**
//	 * 根据产品图号查询该产品是否存在
//	 * @param prdInfo
//	 * @return
//	 */
//	int selectCountByDrawingNo(PrdInfo prdInfo);

	/**
	 * 删除产品信息及相关BOM信息
	 * @param ids
	 * @return
	 */
	boolean deletePrdAndBom(List<Long> ids, List<String> productDrawingNos);

//	/**
//	 * 查询产品详情，以及产品标识为"定额"的下级材料
//	 * @param prdInfo
//	 * @return
//	 */
//	PrdInfoVO getDetailWithBom(PrdInfo prdInfo);
//
//
//	/**
//	 * 产品列表，带产品类型
//	 * @return
//	 */
//	List<PrdInfoVO> listWithType();

	/**
	 * 根据更新时间查询产品列表，包含已删除的
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	List<PrdInfo> listWithDeleted(Date startTime, Date endTime);

//	List<PrdInfoVO> selectTopPrdInfoNotPage(PrdInfoVO prdInfo);

//	/**
//	 * 新增产品及bom信息
//	 * @param prdInfoVO
//	 * @return
//	 */
//	boolean savePrdAndBom(PrdInfoVO prdInfoVO);

//	/**
//	 * 修改产品及bom信息
//	 * @param prdInfoVO
//	 * @return
//	 */
//	boolean updatePrdAndBom(PrdInfoVO prdInfoVO);

	/**
	 * 生产产品编码
	 * @return
	 */
	String createProductNo(PrdInfoVO prdInfoVO);

	/**
	 * 根据产品编码查询数量
	 * 包含已删除的
	 * @param prdInfoVO
	 */
	int countByMaterialNo(PrdInfoVO prdInfoVO);


	/**
	 * 根据物料类型和物料组查询所有物料
	 * @param prdInfo
	 * @return
	 */
	List<PrdInfoVO> materialByTypeAndGroup(PrdInfoVO prdInfo);

	/**
	 * 验证产品名称+规格+型号是否重复
	 * @param id
	 * @param materialName
	 * @param specifications
	 * @param model
	 * @return
	 */
    int countByNameSpecModel(Long id, String materialName, String specifications, String model);

    R uploadPrdInfo(Map<String, Object> map);

	void exportPrdInfo(HttpServletRequest request, HttpServletResponse response, PrdInfoVO prdInfo, String ids);

    List<PrdInfoVO> listByNameQua(String prdName, String productType);

    PrdInfoVO findByMaterialNo(String materialNo);

    R updateProductUnitPrice(PrdInfoVO prdInfoVO);

    void exportWaste(HttpServletRequest request, HttpServletResponse response, PrdInfoVO prdInfo, String ids);

    R uploadWaste(Map<String, Object> map);
}
